package com.digital.smartgrow.controller.business;

import com.digital.smartgrow.common.advice.Result;
import com.digital.smartgrow.dto.business.UpJobPageDTO;
import com.digital.smartgrow.entity.business.UpJob;
import com.digital.smartgrow.service.business.UpJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 职评表 前端控制器
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-13
 */
@Api(tags = "职评表")
@RestController
@RequestMapping("${context.prefix}/business/upJob")
public class UpJobController {

    @Autowired
    private UpJobService upJobService;

    @ApiOperation(value = "职评表-分页查询")
    @PostMapping("/list")
    public Object getListByPage(@RequestBody UpJobPageDTO upJobPageDTO){
        return upJobService.getListByPage(upJobPageDTO);
    }

    @ApiOperation(value = "职评表-详情")
    @GetMapping("/{id}")
    public Object getInfo(@PathVariable Integer id){
        if (id == null) return Result.fail("id不能为空");
        return upJobService.getInfo(id);
    }

    @ApiOperation(value = "职评表-删除")
    @DeleteMapping("/{id}")
    public Object removeById(@PathVariable Integer id){
      if (id == null) return Result.fail("id不能为空");
      return upJobService.removeById(id);
    }
    @ApiOperation(value = "职评表-新增")
    @PostMapping()
    public Object add( @RequestBody UpJob upJob){
       return upJobService.save(upJob);
    }

    @ApiOperation(value = "职评表-编辑")
    @PutMapping()
    public Object edit(@RequestBody UpJob upJob){
    if (upJob==null||upJob.getId() == null)
       return Result.fail("id不能为空");
       return upJobService.updateById(upJob);
    }
}
